#!/bin/zsh
#docker run -itd --name hsakdahskdhjhaskhdjkash simon-webui-image:v1 /bin/bash
#docker cp  hsakdahskdhjhaskhdjkash:/root/workspace  ./
#docker rm  -f hsakdahskdhjhaskhdjkash
FOLDER_PATH="workspace"

# 检查文件夹是否存在
if [ -d "$FOLDER_PATH" ]; then
    echo "文件夹已存在，正在删除..."
    rm -rf "$FOLDER_PATH"  # 删除文件夹及其内容
fi

# 创建新的文件夹
mkdir -p "$FOLDER_PATH"
echo "新文件夹已创建: $FOLDER_PATH"


cat <<EOF >  workspace/main.py
# -*- coding: utf-8 -*-
# @Time:    2025-04-11 17:21
# @Author:  simon
# @Email:   yonglonggeng@163.com
# @WeChat:  ddgetget
# @File:    main.py
# @Project: dev-tools
# @Package:
# @Ref:
import os
os.system("uv init")
os.system("uv sync")

import uvicorn

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def index():
    return {"status": "OK"}


if __name__ == '__main__':
    uvicorn.run('main:app', host='0.0.0.0', port=80, reload=True, workers=1)
EOF

cat <<EOF >  workspace/pyproject.toml
[project]
name = "uni-tools-app"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "fastapi>=0.115.12",
    "pymysql>=1.1.1",
    "sqlalchemy>=2.0.41",
    "uvicorn>=0.34.2",
]
EOFcat <<EOF >  workspace/serverice.sh
[project]
name = "uni-tools-app"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "fastapi>=0.115.12",
    "pymysql>=1.1.1",
    "sqlalchemy>=2.0.41",
    "uvicorn>=0.34.2",
]
EOF